<template>
  <div class="page-wrapper">
    <div class="container-fluid">
      <iframe
        :src="url"
        frameborder="0"
        height="1000px%"
        scrolling="auto"
        width="100%"
      ></iframe>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      url: "",
      dataForm: {
        reportName: "",
      },
    };
  },
  methods: {
    link() {
      let reportDir = this.dataForm.reportName.substring(
        0,
        this.dataForm.reportName.lastIndexOf(".")
      );
      this.url =
        "/proxyApi/testReport/" + reportDir.replace(/\\/g, "/") + "/index.html";
    },
  },
  created() {
    //设置路由跳转

    // this.dataForm.reportName = this.$route.query.reportName
    //设置路由跳转
    this.$set(this.dataForm, "reportName", this.$route.query.reportName);
    console.log(this.dataForm.reportName);
    console.log();

    this.link();
  },
  watch: {
    $route(now, old) {
      //监控路由变换，控制返回按钮的显示
      if (now.path == "/home") {
        this.isShow = false;
      } else {
        // 监听的上一次路由的值,从路由的值中,初始化传的参数,放到监听里面,是为了让页面不停的跳转使用,
        // 不建议放到created中,因为created 只加载使用一次
        console.log("路由的caseid", this.$route.query.caseId);
        this.dataForm.reportName = this.$route.query.reportName;
        console.log("路由的caseid", this.dataForm.reportName);
        this.link();
        this.isShow = true;
      }
    },
  },
};
</script>

<style scoped>
</style>
